<li>
  <p>
    {# if both of them have URLs #}
    {% if change.new_url != "" and change.old_url != "" %}

      {{ _('Changed the license of {pkg_link} to {new_link} (previously {old_link})').format(
            pkg_link = '<a href="{pkg_url}">{pkg_name}</a>'.format(
              pkg_url = h.url_for(controller='dataset',
                                  action='read', id=change.pkg_id),
              pkg_name = change.title
            )|safe,
            new_link = '<a href={new_url}>{new_title}</a>'.format(
              new_url = change.new_url,
              new_title = change.new_title
            )|safe,
            old_link = '<a href={old_url}>{old_title}</a>'.format(
              old_url = change.old_url,
              old_title = change.old_title
            )|safe
      ) }}

    {# if only the new one has a URL #}
    {% elif change.new_url != "" and change.old_url == "" %}

      {{ _('Changed the license of {pkg_link} to {new_link} (previously {old_title})').format(
            pkg_link = '<a href="{pkg_url}">{pkg_name}</a>'.format(
              pkg_url = h.url_for(controller='dataset',
                                  action='read', id=change.pkg_id),
              pkg_name = change.title
            )|safe,
            new_link = '<a href="{new_url}">{new_title}</a>'.format(
              new_url = change.new_url,
              new_title = change.new_title,
            )|safe,
            old_title = change.old_title
        ) }}

    {# if only the old one has a URL #}
    {% elif change.new_url == "" and change.old_url != "" %}

    {{ _('Changed the license of {pkg_link} to {new_title} (previously {old_link})').format(
          pkg_link = '<a href="{pkg_url}">{pkg_name}</a>'.format(
            pkg_url = h.url_for(controller='dataset',
                                action='read', id=change.pkg_id),
            pkg_name = change.title
          )|safe,
          new_title = change.new_title,
          old_link = '<a href="{old_url}">{old_title}</a>'.format(
            old_url = change.old_url,
            old_title = change.old_title
          )|safe
      )}}

    {# otherwise neither has a URL #}
    {% else %}


      {{ _('Changed the license of {pkg_link} to {new_title} (previously {old_title})').format(
            pkg_link = '<a href="{pkg_url}">{pkg_name}</a>'.format(
              pkg_url = h.url_for(controller='dataset',
                                  action='read', id=change.pkg_id),
              pkg_name = change.title
            )|safe,
            new_title = change.new_title,
            old_title = change.old_title
        )|safe }}

    {% endif %}
  </p>
</li>
